import wx
import hashlib, uuid, requests


def getdisk():
	#获取硬盘号
	a = uuid.uuid1()
	a = str(a).split('-')[-1]
	b = a.encode(encoding='utf-8')
	m = hashlib.md5()
	m.update(b)
	str_md5 = m.hexdigest()
	return str_md5


def readpassword():
	#验证是否注册
	return True
				
			
		
class Register(wx.Dialog):

	def __init__(self, window): #再初始化该类特有的属性
		wx.Dialog.__init__(self, None, id=-1, title='POI-Player V1.0 注册') #先初始化父类的属性
		self.window = window
		self.box = wx.BoxSizer(wx.VERTICAL)
		self.buildbox()
		self.SetSizerAndFit(self.box)
		
	def buildbox(self):
		boxbutton = wx.BoxSizer(wx.HORIZONTAL)
		#text = wx.StaticText(self, -1, '请求码')
		#text2 = wx.TextCtrl(self, wx.NewId(), getdisk())
		text3 = wx.StaticText(self, -1, '请输入邮箱，点击发送按钮')
		self.inputcode = wx.TextCtrl(self, style=wx.TE_MULTILINE)
		
		okButton = wx.Button(self, wx.ID_OK, "发送")
		okButton.SetDefault()
		cancelButton = wx.Button(self, wx.ID_CANCEL, "取消")
		boxbutton.Add(okButton,1, wx.EXPAND | wx.ALL, 10)
		boxbutton.Add(cancelButton,1, wx.EXPAND | wx.ALL, 10)
		#self.box.Add(text, 0,wx.LEFT, 10)
		#self.box.Add(text2, 1, wx.EXPAND| wx.ALL, 10)
		self.box.Add(text3, 0,wx.LEFT, 10)
		self.box.Add(self.inputcode, 1, wx.EXPAND| wx.ALL, 10)
		self.box.Add(boxbutton, 0, wx.EXPAND)
		self.Bind(wx.EVT_BUTTON, self.checkmac, okButton)
	
				
	def checkmac(self,event):
		#查看输入的激活码是否有效
		if readpassword():
			#注册成功
			self.window.output.AppendText('注册成功\n')
			self.Destroy()
		else:
			wx.LogError("激活码无效")
			
		
if __name__=='__main__':
	a = readpassword()
	print(a)